<?php
class MCache extends BaseModelMemCached {
	public function __construct() {
		$_svr = explode(' ', IDCMC_SERVERS);
		$_main_svr = $_svr[0] ? $_svr[0] : '';
		$_rest_svr = array_shift($_svr);
		parent::__construct($_main_svr,$_svr);
	}
	/**
	* get date from cache
	* @params string $key
	* @params string $class name
	* @params string $method
	* @params mixed array $args
	* @params int unsigned $cacheTime
	*/
	public static function gD($key, $class, $method, $args, $cacheTime) {
		$mc = new MCache();
		$info = $mc->get($key);
		if (!empty($info)) {
			return $info;
		}
		$atomKey = $key."_block";
		$atomExipres = 5;
		$atomValue = 1;
		if ($mc->add($atomKey, $atomValue, $atomExpires)) {
			$info = call_user_func_array(array($class,$method), $args);
			if (empty($info)) {
				return false;
			}
			$mc->set($key, $info, $cacheTime);
			return $info;
		}
		return call_user_func_array(array($class,$method), $args);
	}
	/**
	* delete data from cache
	* @params string $key
	* @return bool
	*/
	public static function dD($key) {
		if (false === self::rD($key)) {
			return true;
		}
		$mc = new MCache();
		return $mc->delete($key);
	}
	/**
	* get data from key
	* @param string $key
	* @return bool
	*/
	public static function rD($key) {
		$mc = new MCache();
		return $mc->get($key);
	}
}
?>
